﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JSOCTNet.IBIZ;
using System.Collections;

namespace TestSendFile
{
    class Program
    {
        static void Main(string[] args)
        {
            OSSConfig ossConfig = new OSSConfig();
            ossConfig.serverAddress = "https://oss-cn-hangzhou.aliyuncs.com";
            ossConfig.userName = "LTAIP6fuTwSqFzNn";
            ossConfig.passWord = "PC2jscHnAsnRMdvQegng7U0y1MpWWj";
            ossConfig.fileStoreType = "OSS";
            ossConfig.bucket = "publicdata";

            string config = Newtonsoft.Json.JsonConvert.SerializeObject(ossConfig);

            FileDescription fileDescription = new FileDescription();
            fileDescription.fileName = @"E:\pic\Jellyfish.jpg";
            fileDescription.attributes["COMMAND_ID"] = "NISSP_IMG_PARK_IN";
            fileDescription.attributes["PK_STR"] = "20170926";
            fileDescription.attributes["RECORD_ID"] = "d61db8c0faf046c5940aa663e399fe56";

            ISendFile iSendFile = FactorySendFile.CreateISendFile();
            iSendFile.Init(config);
            string file = "{\"uid\":\"02f88f0edf9f421ea3e55f288d637e82\",\"fileName\":\"E:\\\\pic\\\\Jellyfish.jpg\",\"fileCategory\":0,\"fileSize\":0,\"fileType\":0,\"attributes\":{\"COMMAND_ID\":\"NISSP_IMG_PARK_IN\",\"PK_STR\":\"20170926\",\"NISSP_ID\":\"02f88f0edf9f421ea3e55f288d637e82\",\"RECORD_ID\":\"d61db8c0faf046c5940aa663e399fe56\"}}";
            string fileTemp = Newtonsoft.Json.JsonConvert.SerializeObject(fileDescription);
            int intResult = iSendFile.Send("00007889", file);
            Console.ReadLine();

            string s = "粤-C5471501_CRD000000_20180320155813_2号出口_300400010023_01.jpg";
            string[] array = s.Split('_');
            string PK_STR = array[2].Substring(0,8);
            Console.WriteLine(PK_STR);

        }
    }

    public class OSSConfig
    {
        /// <summary>
        /// 服务器地址
        /// </summary>
        public string serverAddress { get; set; }

        /// <summary>
        /// 服务器登录账户
        /// </summary>
        public string userName { get; set; }

        /// <summary>
        /// 服务器登录密码
        /// </summary>
        public string passWord { get; set; }

        /// <summary>
        /// 服务器存储空间
        /// </summary>
        public string bucket { get; set; }

        /// <summary>
        /// 服务器类型
        /// </summary>
        public string fileStoreType { get; set; }
    }


    public class FileDescription
    {
        public FileDescription()
        {
            this.attributes = new Hashtable();
            this.fileCategory = 0;
            this.fileName = "";
            this.fileSize = 0;
            this.fileType = 0;
            this.uid = "";
        }

        public Hashtable attributes { get; set; }
        public int fileCategory { get; set; }
        public string fileName { get; set; }
        public int fileSize { get; set; }
        public int fileType { get; set; }
        public string uid { get; set; }
    }
}
